public virtual class Collection extends AtomBase {
	
	public String href { get; set; }
	public List<Categories> categories { 
		get {
			if (categories == null) {
				categories = new List<Categories>();
			}
			return categories;
		}
		set; 
	}
	public Collection() {}
	
	public Collection(String title) {
		setTitle(title);
	}
	
	public Collection(XmlStreamReader reader) {
		super(reader);
		return;
	}
	
	public override void handleStartTag(XmlStreamReader reader, String nodeName) {
		System.debug(LoggingLevel.FINE, '\n\nFirst feed node is: ' + reader.getLocalName() + '\n');
		String nodeText;
  
		while (reader.hasNext()) {
	        if (reader.getEventType() == XmlTag.START_ELEMENT) {
				nodeName = reader.getLocalName();
				nodeText = '';
	        
	        	handleAttributes(reader, nodeName);
	       	
	        	System.debug(LoggingLevel.FINE, '\n\nSTART_ELEMENT: ' + nodeName + '\n');
	        	
				if (nodeName == 'categories') { 
					Categories c = new Categories(reader);
	   				categories.add(c); 
				} else if (nodeName == 'collection') {
					//skip
				} else {
					System.debug(LoggingLevel.FINE, '\n\nUnhandled tag name: ' + nodeName + '\n');
				}
				reader.next();
			} else if (reader.getEventType() == XmlTag.CHARACTERS) {
				if ( ! reader.isWhitespace()) { 
                    nodeText += reader.getText();  // add text to current element
                }
                reader.next();
	        } else if (reader.getEventType() == XmlTag.END_ELEMENT) {

	        	System.debug(LoggingLevel.FINE, '\n\nEND_ELEMENT: ' + reader.getLocalName() + '\n');
				if (reader.getLocalName() == 'collection') {
					return;
				} 
	   			reader.next();
	        }
		}				
	} 
	
	public String getHref() {
		return href;
	}
	
	public override String ToAPP() {
		return '';
	}
	
	private void handleAttributes(XmlStreamReader reader, String tagName) {
		for (integer i=0; i<reader.getAttributeCount(); i++) {
      		String name = reader.getAttributeLocalName(i);
       		String value = reader.getAttributeValueAt(i);
       		if (tagName == 'collection') {
       			if (name == 'href') {
       				href = value;
       			} 
       		}
        }
       
	}
		
}